<#macro categoryTree parentId=''>
    <@cms.categoryList advanced=true parentId=parentId pageSize=500>
        <#list page.list as a>
            <li>
                <a href="cmsPlace/lookup_content_list.html?categoryId=${a.id}" class="exclude-translate" target="ajax" rel="lookup_content_list">${a.name!}</a>
            <#if a.childIds?has_content>
                <ul>
                    <@categoryTree a.id/>
                </ul>
            </#if>
            </li>
        </#list>
    </@cms.categoryList>
</#macro>
<#macro lookupTree parentId=''>
    <@cms.categoryList advanced=true parentId=parentId>
        <#list page.list as a>
            <li>
                <a href="javascript:;" class="exclude-translate" onclick="$.bringBack({itemType:'category',itemId:'${a.id}',title:'${(a.name?js_string)!}',url:'${a.url!}'});return false;">${a.name!}</a>
            <#if a.childIds?has_content>
                <ul>
                    <@lookupTree a.id/>
                </ul>
            </#if>
            </li>
        </#list>
    </@cms.categoryList>
</#macro>
<#macro pageTree filepath=''>
    <@tools.fileList path=filepath orderField='createDate'>
        <#list list as a>
            <#local path=filepath+'/'+a.fileName>
            <li>
            <@tools.metadata path=path>
                <#if a.directory>
                    <a href="javascript:;" onclick="return false;">
                        ${(object.alias)?has_content?then(object.alias+' ('+a.fileName+')',a.fileName)}
                    </a>
                    <ul>
                        <@pageTree path/>
                    </ul>
                <#else>
                    <#if site.useStatic&&(object.publishPath)?has_content>
                        <a href="javascript:;" onclick="$.bringBack({itemType:'page',title:'${(object.alias)!}',url:'${site.sitePath+(object.publishPath?starts_with('/'))?then(object.publishPath?keep_after('/'),object.publishPath)}'});return false;">
                            [<@t.page 'static_page'/>] ${(object.alias)?has_content?then(object.alias+' ('+a.fileName+')',a.fileName)}
                        </a>
                    </#if>
                    <#if (object.useDynamic)?has_content&&object.useDynamic>
                        <a href="javascript:;" onclick="$.bringBack({itemType:'page',title:'${(object.alias)!}',url:'${site.dynamicPath+(path?starts_with('/'))?then(path?keep_after('/'),path)}<#if (object.acceptParameters)?has_content>?<#list object.acceptParameters?split(',') as a>${a}=<#if 'content'=(object.parameterTypeMap[a].type)!><@cms.contentList pageSize=1><#list page.list as a>${a.id}</#list></@cms.contentList><#elseif 'category'=(object.parameterTypeMap[a].type)!><@cms.categoryList pageSize=1><#list page.list as a>${a.id}</#list></@cms.categoryList></#if><#sep>&</#list></#if>'});return false;">
                            [<@t.page 'dynamic_page'/>] ${(object.alias)?has_content?then(object.alias+' ('+a.fileName+')',a.fileName)}
                        </a>
                    </#if>
                </#if>
            </@tools.metadata>
            </li>
        <#else>
            <li><a><@t.page 'empty_directory'/></a></li>
        </#list>
    </@tools.fileList>
</#macro>
<#assign itemTypes=acceptItemTypes?has_content?then(acceptItemTypes?split(','),['page','content','category'])/>
<div class="pageContent">
    <div class="tabs">
        <div class="tabsHeader">
            <div class="tabsHeaderContent">
                <ul>
                <#if itemTypes?seq_contains('content')>
                    <li><a href="javascript:;" onclick="return false;"><@t.page 'content'/></a></li>
                </#if>
                <#if itemTypes?seq_contains('category')>
                    <li><a href="javascript:;" onclick="return false;"><@t.page 'category'/></a></li>
                </#if>
                <#if itemTypes?seq_contains('page')>
                    <li><a href="javascript:;" onclick="return false;"><@t.page 'page'/></a></li>
                </#if>
                </ul>
            </div>
        </div>
        <div class="tabsContent">
        <#if itemTypes?seq_contains('content')>
            <div class="pageContent" layoutH>
                <div class="unitBox leftPageContent">
                    <ul class="tree treeFolder" layoutH>
                        <li>
                            <a href="cmsPlace/lookup_content_list.html" target="ajax" rel="lookup_content_list"><@t.page 'category'/></a>
                            <ul>
                                <@categoryTree/>
                            </ul>
                        </li>
                     </ul>
                </div>
                <div id="lookup_content_list" class="unitBox rightPageContent" layoutH>
                    <#include "lookup_content_list.html"/>
                </div>
            </div>
        </#if>
        <#if itemTypes?seq_contains('category')>
            <div class="pageFormContent" layoutH>
                <ul class="tree treeFolder">
                    <@lookupTree/>
                </ul>
            </div>
        </#if>
        <#if itemTypes?seq_contains('page')>
            <div class="pageFormContent" layoutH>
                <ul class="tree treeFolder">
                    <@pageTree/>
                </ul>
            </div>
        </#if>
        </div>
    </div>
    <div class="formBar">
        <ul>
            <li><button class="button" type="button" onclick="$.bringBack({itemType:'',itemId:''});return false;"><@t.page 'button.clear_select'/></li>
            <li><button class="close button" type="button"><@t.page 'button.close'/></li>
        </ul>
    </div>
</div>